home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SNNSV32.ZIP / SNNSv3.2 / xgui / sources / ui_infoP.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-25  |  46.5 KB  |  1,623 lines

  1. /*****************************************************************************
  2.   FILE           : ui_infoP.c
  3.   SHORTNAME      : infoP.c
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        :
  7.   NOTES          :
  8.  
  9.   AUTHOR         : Tilman Sommer
  10.   DATE           : 1.2.1990
  11.  
  12.   CHANGED BY     :
  13.   IDENTIFICATION : @(#)ui_infoP.c    1.15 4/7/94
  14.   SCCS VERSION   : 1.15
  15.   LAST CHANGE    : 4/7/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.              
  19. ******************************************************************************/
  20.  
  21. #include <stdio.h>
  22.  
  23. #include "ui.h"
  24. #include "ui_netGraph.h"
  25.  
  26. #include "kr_ui.h"
  27.  
  28. #include <X11/Xaw/List.h>
  29. #include "ui_utilP.h"
  30. #include "ui_xWidgets.h"
  31. #include "ui_textP.h"
  32. #include "ui_remoteP.h"
  33. #include "ui_mainP.h"
  34. #include "ui_lists.h"
  35. #include "ui_display.h"
  36. #include "ui_confirmer.h"
  37. #include "ui_netUpdate.h"
  38. #include "ui_selection.h"
  39. #include "ui_action.h"
  40. #include "ui_info.h"
  41. #include "ui_layer.h"
  42.  
  43.  
  44. #include "ui_infoP.ph"
  45.  
  46.  
  47. /*****************************************************************************
  48.   FUNCTION : ui_info_initLinkStruct
  49.  
  50.   PURPOSE  : init link attributs 
  51.   RETURNS  : void
  52.   NOTES    :
  53.  
  54.   UPDATE   : 20.9.1990
  55. ******************************************************************************/
  56.  
  57. static void ui_info_initLinkStruct(void)
  58.  
  59. {
  60.     ui_link.weight          = 0.0;
  61.     ui_link.siteValue       = 0.0;
  62.     ui_link.siteName[0]     = '\0';
  63.     ui_link.siteFuncName[0] = '\0';
  64. }
  65.  
  66.  
  67. /*****************************************************************************
  68.   FUNCTION : ui_info_initUnitStruct
  69.  
  70.   PURPOSE  : init attributs specified unit (target or source)
  71.   RERURNS  : struct UnitAttributeType  *
  72.   NOTES    :
  73.  
  74.   UPDATE   : 15.8.1990
  75. ******************************************************************************/
  76.  
  77. void ui_info_initUnitStruct(struct UnitAttributeType *unit)
  78.  
  79. {
  80.     (*unit).no       = 0;
  81.     (*unit).subnetNo = 0; /* main net */
  82.     (*unit).layers   = 1; /* first layer only */
  83.     (*unit).frozen   = FALSE;
  84.     sprintf((*unit).name, "");
  85.     sprintf((*unit).ftype, "");
  86.     sprintf((*unit).actFuncName, "");
  87.     sprintf((*unit).outFuncName, "");
  88.     (*unit).iotype   = HIDDEN;
  89.     (*unit).act      = 0.0;
  90.     (*unit).i_act    = 0.0;
  91.     (*unit).out      = 0.0;
  92.     (*unit).bias     = 0.0;
  93. }
  94.  
  95.  
  96. /*****************************************************************************
  97.   FUNCTION : ui_info_setLinkItems
  98.  
  99.   PURPOSE  : display data in the panel
  100.   RETURNS  : void
  101.   NOTES    :
  102.  
  103.   UPDATE   : 20.9.1990
  104. ******************************************************************************/
  105.  
  106. static void ui_info_setLinkItems(void)
  107.  
  108. {
  109.     char buf[20];
  110.  
  111.     sprintf(buf,"%9.5f",ui_link.weight);
  112.     ui_cutTrailingZeros(buf);
  113.     ui_xSetString(ui_linkWidgets.weight, buf);
  114.     
  115.     if (strlen(ui_link.siteName)) {
  116.     sprintf(buf,"%9.5f",ui_link.siteValue);
  117.     ui_cutTrailingZeros(buf);
  118.     ui_xSetLabel(ui_linkWidgets.siteValue, buf);
  119.     ui_xSetLabel(ui_linkWidgets.siteName, ui_link.siteName);
  120.     ui_xSetLabel(ui_linkWidgets.siteFuncName, ui_link.siteFuncName);
  121.     } else {
  122.     ui_xSetLabel(ui_linkWidgets.siteValue, "");
  123.     ui_xSetLabel(ui_linkWidgets.siteName, "");
  124.     ui_xSetLabel(ui_linkWidgets.siteFuncName, "");
  125.     }
  126. }
  127.  
  128.  
  129. /*****************************************************************************
  130.   FUNCTION : ui_info_setUnitItems
  131.  
  132.   PURPOSE  : display values in the unit-info-panel from the network data 
  133.              structure via the kernel
  134.   RETURNS  : alteration of unit-info-panel
  135.   NOTES    :
  136.  
  137.   UPDATES  :
  138. *****************************************************************************/
  139.  
  140. void ui_info_setUnitItems(struct UnitWidgetType unitWidgets, 
  141.      struct UnitAttributeType  unit)
  142.  
  143. {
  144.     char         buf[MAX_NAME_LENGTH];
  145.  
  146.     /* display unit number */
  147.     if (krui_setCurrentUnit(unit.no) != UI_SET_OK  /* error: unit not valid */)
  148.     unit.no = 0;
  149.  
  150.     if (ui_infoIsCreated) {
  151.  
  152.     ui_xSetToggleState(unitWidgets.frozen, unit.frozen);
  153.  
  154.     sprintf(buf,"%d", unit.no);
  155.     ui_xSetLabel(unitWidgets.no, buf);
  156.  
  157.     sprintf(buf,"%d", unit.subnetNo);
  158.     ui_xSetLabel(unitWidgets.subnetNo, buf);
  159.  
  160.     sprintf(buf,"%s", unit.outFuncName);
  161.     ui_xSetLabel(unitWidgets.outFuncName, buf);
  162.  
  163.     sprintf(buf,"%s", unit.actFuncName);
  164.     ui_xSetLabel(unitWidgets.actFuncName, buf);
  165.  
  166.     sprintf(buf,"%s", unit.ftype);
  167.     ui_xSetLabel(unitWidgets.ftype, buf);
  168.  
  169.     sprintf(buf,"%s", unit.name);
  170.     ui_xSetString(unitWidgets.name, buf); 
  171.  
  172.     switch (unit.iotype) {
  173.       case HIDDEN:     
  174.         ui_xSetLabel(unitWidgets.iotype, "H");
  175.         break;
  176.       case INPUT:     
  177.         ui_xSetLabel(unitWidgets.iotype, "I");
  178.         break;
  179.       case OUTPUT:     
  180.         ui_xSetLabel(unitWidgets.iotype, "O");
  181.         break;
  182.       case DUAL:     
  183.         ui_xSetLabel(unitWidgets.iotype, "D");
  184.         break;
  185.       case SPECIAL:     
  186.         ui_xSetLabel(unitWidgets.iotype, "S");
  187.         break;
  188.           case SPECIAL_I:
  189.             ui_xSetLabel(unitWidgets.iotype, "SI");
  190.             break;
  191.           case SPECIAL_O:       
  192.             ui_xSetLabel(unitWidgets.iotype, "SO");
  193.             break;
  194.           case SPECIAL_H:       
  195.             ui_xSetLabel(unitWidgets.iotype, "SH");
  196.             break;
  197.           case SPECIAL_D:       
  198.             ui_xSetLabel(unitWidgets.iotype, "SD");
  199.             break;
  200.       case UNKNOWN:     
  201.         ui_xSetLabel(unitWidgets.iotype, "-");
  202.         break;
  203.     }    
  204.  
  205.     sprintf(buf,"%8.5f", unit.act);
  206.     ui_cutTrailingZeros(buf);
  207.     ui_xSetString(unitWidgets.act, buf); 
  208.  
  209.     sprintf(buf,"%8.5f", unit.i_act);
  210.     ui_cutTrailingZeros(buf);
  211.     ui_xSetString(unitWidgets.i_act, buf); 
  212.  
  213.     sprintf(buf,"%8.5f", unit.out);
  214.     ui_cutTrailingZeros(buf);
  215.     ui_xSetString(unitWidgets.out, buf); 
  216.     
  217.     sprintf(buf,"%8.5f", unit.bias);
  218.     ui_cutTrailingZeros(buf);
  219.     ui_xSetString(unitWidgets.bias, buf);
  220.     }
  221. }
  222.  
  223.  
  224. /*****************************************************************************
  225.   FUNCTION : ui_info_getAllSiteData
  226.  
  227.   PURPOSE  : get all link data, if a current site exists
  228.   RETURNS  : void
  229.   NOTES    : a current site must exist !!!!!
  230.  
  231.   UPDATE   : 20.9.1990
  232. ******************************************************************************/
  233.  
  234. static void ui_info_getAllSiteData(void)
  235.  
  236. {
  237.     ui_link.siteValue = (FlintType) krui_getSiteValue();
  238.  
  239.     sprintf(ui_link.siteName,"%s",     krui_getSiteName());
  240.     sprintf(ui_link.siteFuncName,"%s", krui_getSiteFuncName());
  241.  
  242.  
  243. /*****************************************************************************
  244.   FUNCTION : ui_info_getAllUnitData
  245.  
  246.   PURPOSE  : get all unit attributes from the network structure via kernel
  247.   RETURNS  : in a parameter (unit) all attributes
  248.   NOTES    :
  249.  
  250.   UPDATES  :
  251. *****************************************************************************/
  252.  
  253. static void ui_info_getAllUnitData(int unitNo, struct UnitAttributeType *unit)
  254.  
  255. {
  256.     (*unit).no          = unitNo;
  257.     (*unit).subnetNo    = krui_getUnitSubnetNo(unitNo);
  258.     (*unit).frozen      = krui_isUnitFrozen(unitNo);
  259.     (*unit).layers      = krui_getUnitLayerNo(unitNo);
  260.     (*unit).iotype      = krui_getUnitTType(unitNo);
  261.     (*unit).act         = krui_getUnitActivation(unitNo);
  262.     (*unit).i_act       = krui_getUnitInitialActivation(unitNo);
  263.     (*unit).out         = krui_getUnitOutput(unitNo);
  264.     (*unit).bias        = krui_getUnitBias(unitNo);
  265.  
  266.     if (krui_getUnitName(unitNo) != NULL)
  267.     sprintf((*unit).name       ,"%s", krui_getUnitName(unitNo));
  268.     else
  269.     sprintf((*unit).name       ,"");
  270.     if (krui_getUnitFTypeName(unitNo) != NULL)
  271.     sprintf((*unit).ftype      ,"%s", krui_getUnitFTypeName(unitNo));
  272.     else
  273.     sprintf((*unit).ftype       ,"");
  274.     sprintf((*unit).outFuncName,"%s", krui_getUnitOutFuncName(unitNo));
  275.     sprintf((*unit).actFuncName,"%s", krui_getUnitActFuncName(unitNo));
  276.  
  277.     krui_getUnitPosition(unitNo, &(*unit).gridPos);
  278. }
  279.  
  280.  
  281. /*****************************************************************************
  282.   FUNCTION : ui_info_getDisplayedUnitAttributes 
  283.  
  284.   PURPOSE  : get the the displayed attributes: 
  285.              Name, Act, I_Act, Out and Bias
  286.   RETURNS  : void
  287.   NOTES    : 
  288.  
  289.   UPDATES  :
  290. *****************************************************************************/
  291.  
  292. void ui_info_getDisplayedUnitAttributes(struct UnitWidgetType *unitWidgets,
  293.     struct UnitAttributeType  *unit)
  294.  
  295. {
  296.     if (unitWidgets == &ui_sourceWidgets) 
  297.     *unit = ui_sourceUnit;
  298.     else
  299.     *unit = ui_targetUnit;
  300.  
  301.     if (ui_infoIsCreated) {
  302.     ui_xStringFromAsciiWidget((*unitWidgets).name, (*unit).name, 
  303.                   MAX_NAME_LENGTH);
  304.     if (((*unit).name == NULL) OR
  305.         (strlen(((*unit).name))<1))
  306.         sprintf((*unit).name,"");
  307.     else
  308.         ui_correctName((*unit).name); /* replace white space */
  309.     (*unit).act   = 
  310.         (float) ui_xFloatFromAsciiWidget((*unitWidgets).act);
  311.     (*unit).i_act = 
  312.         (float) ui_xFloatFromAsciiWidget((*unitWidgets).i_act);
  313.     (*unit).out   = 
  314.         (float) ui_xFloatFromAsciiWidget((*unitWidgets).out);
  315.     (*unit).bias  = 
  316.         (float) ui_xFloatFromAsciiWidget((*unitWidgets).bias);
  317.     }
  318. }
  319.  
  320.  
  321. /*****************************************************************************
  322.   FUNCTION : ui_info_storeAttributes
  323.  
  324.   PURPOSE  : stores all attributes from unitAttributes to unit unitNo.
  325.   RETURNS  : void
  326.   NOTES    : The unitNo is not set, because it can't be set!
  327.              The layer and the subnet number will be set as well. This must
  328.              be corrected by the caller if desired.
  329.          The GUI unit creation routine will do the following assignment:
  330.          layer    := currentLayer (only) in currentWindow
  331.          subNetNo := subNetNo of currentWindow
  332.  
  333.   UPDATES  : 
  334. *****************************************************************************/
  335.  
  336. void ui_info_storeAttributes(int unitNo, struct UnitAttributeType unit)
  337.  
  338. {
  339.     if (strlen(unit.name) OR (krui_getUnitName(unitNo) != NULL)) {
  340.     ui_checkError(krui_setUnitName(unitNo, unit.name));
  341.     }
  342.     if (strlen(unit.ftype) OR (krui_getUnitFTypeName(unitNo) != NULL)) {
  343.     ui_checkError(krui_setUnitFType(unitNo, unit.ftype));
  344.     }
  345.     if (unit.iotype == UNKNOWN)
  346.     ui_checkError(krui_setUnitTType(unitNo, HIDDEN));
  347.     else
  348.     ui_checkError(krui_setUnitTType(unitNo, unit.iotype));
  349.  
  350.     
  351.     krui_setUnitSubnetNo         (unitNo, unit.subnetNo);
  352.     krui_setUnitLayerNo          (unitNo, (int) unit.layers);
  353.     if (NOT (strcmp(unit.actFuncName, krui_getUnitActFuncName(unitNo)) == 0))
  354.     krui_setUnitActFunc      (unitNo, unit.actFuncName);
  355.     if (NOT (strcmp(unit.outFuncName, krui_getUnitOutFuncName(unitNo)) == 0))
  356.     krui_setUnitOutFunc      (unitNo, unit.outFuncName);
  357.     krui_setUnitActivation       (unitNo, unit.act);
  358.     krui_setUnitInitialActivation(unitNo, unit.i_act);
  359.     krui_setUnitOutput           (unitNo, unit.out);
  360.     krui_setUnitBias             (unitNo, unit.bias);
  361.  
  362.     if (unit.frozen)
  363.     krui_freezeUnit(unitNo);
  364.     else
  365.     krui_unfreezeUnit(unitNo);
  366. }
  367.  
  368.  
  369. /*****************************************************************************
  370.   FUNCTION : ui_info_anyUnitSelected          
  371.  
  372.   PURPOSE  : test, whether the displayed source/target unit is valid.
  373.   RETURNS  : true, if the displayed unit is ok.
  374.   NOTES    :
  375.  
  376.   UPDATES  :
  377. *****************************************************************************/
  378.  
  379. static Bool ui_info_anyUnitSelected(FlagType flag)
  380.  
  381. {
  382.     Bool  selected;
  383.     int   unitNo;
  384.     char  buf[10], buf2[50];
  385.  
  386.     if (flag == UI_SOURCE) {
  387.     sprintf(buf,"source");
  388.     unitNo = ui_sourceUnit.no;
  389.     } else {
  390.     sprintf(buf,"target");
  391.     unitNo = ui_targetUnit.no;
  392.     }
  393.     
  394.     if (NOT (selected = (krui_setCurrentUnit(unitNo) == UI_SET_OK))) {
  395.     sprintf(buf2,"No %s unit selected !",buf);
  396.     ui_printMessage(buf2);
  397.     }
  398.     return(selected);
  399. }
  400.  
  401.  
  402. /*****************************************************************************
  403.   FUNCTION : ui_info_displayList
  404.  
  405.   PURPOSE  : popup the list panel
  406.   RETURNS  : void
  407.   NOTES    : 
  408.  
  409.   UPDATES  :
  410. *****************************************************************************/
  411.  
  412. void ui_info_displayList(Widget w, struct SimpleListType *listDescriptorPtr, 
  413.     caddr_t call_data)
  414.  
  415. {
  416.     Arg        args[5];
  417.     Position    x, y;
  418.     Dimension    width, height;
  419.     Cardinal    n;
  420.  
  421.     /* Upper left corner will be in the center of the calling button */
  422.  
  423.     n = 0;
  424.     XtSetArg(args[0], XtNwidth, &width); n++;
  425.     XtSetArg(args[1], XtNheight, &height); n++;
  426.     XtGetValues(listDescriptorPtr->widgetPtr, args, n);
  427.     XtTranslateCoords(listDescriptorPtr->widgetPtr, 
  428.               (Position) (width / 2), (Position) (height / 2),
  429.               &x, &y);
  430.  
  431.     ui_listPopup(listDescriptorPtr,x,y); /* absolute screen coordinates */
  432. }
  433.  
  434.  
  435. /*****************************************************************************
  436.   FUNCTION : ui_info_setDefault
  437.  
  438.   PURPOSE  : copies the value in ui_defUnit and sets kernel defaults
  439.   RETURNS  : void
  440.   NOTES    :
  441.  
  442.   UPDATE   : 27.9.90
  443. ******************************************************************************/
  444.  
  445. void ui_info_setDefault(Widget w, int structure, caddr_t call_data)
  446.  
  447. {
  448.     struct UnitAttributeType  unit;
  449.  
  450.     if (structure == UI_SOURCE) 
  451.     ui_info_getDisplayedUnitAttributes(&ui_sourceWidgets, &ui_defUnit);
  452.     else 
  453.     ui_info_getDisplayedUnitAttributes(&ui_targetWidgets, &ui_defUnit);
  454.     
  455. /* Old, wrong version :
  456.     switch (structure) {
  457.       case UI_SOURCE: 
  458.     ui_defUnit = ui_sourceUnit;
  459.     break;
  460.       case UI_TARGET: 
  461.     ui_defUnit = ui_targetUnit;
  462.     break;
  463.     }
  464. */
  465.     ui_checkError(krui_setUnitDefaults(ui_defUnit.act, ui_defUnit.bias,
  466.                        ui_defUnit.iotype, ui_defUnit.subnetNo, 
  467.                        ui_defUnit.layers, 
  468.                        ui_defUnit.actFuncName, 
  469.                        ui_defUnit.outFuncName));
  470. }
  471.  
  472.  
  473. /*****************************************************************************
  474.   FUNCTION : ui_info_freezeUnit
  475.  
  476.   PURPOSE  : toggles the value frozen in the specified unit-structure
  477.   RETURNS  : void
  478.   NOTES    :
  479.  
  480.   UPDATE   : 26.8.1990
  481. ******************************************************************************/
  482.  
  483. void ui_info_freezeUnit(Widget w, int structure, caddr_t call_data)
  484.  
  485. {
  486.     switch (structure) {
  487.       case UI_SOURCE: 
  488.     ui_sourceUnit.frozen = NOT ui_sourceUnit.frozen;
  489.     break;
  490.       case UI_TARGET: 
  491.     ui_targetUnit.frozen = NOT ui_targetUnit.frozen;
  492.     break;
  493.     }
  494. }
  495.  
  496.  
  497. /*****************************************************************************
  498.   FUNCTION : ui_info_assignLayer
  499.  
  500.   PURPOSE  : popup the layer assignment window.
  501.   RETURNS  : void
  502.   NOTES    : 
  503.  
  504.   UPDATES  :
  505. *****************************************************************************/
  506.  
  507. void ui_info_assignLayer(Widget w, struct InfoCallLayerStruct *callLayerPtr, 
  508.     caddr_t call_data)
  509.  
  510. {
  511.     struct UnitAttributeType  *unitPtr;
  512.     Arg        args[5];
  513.     Position    x, y;
  514.     Dimension    width, height;
  515.     Cardinal    n;
  516.  
  517.     /* Upper left corner will be in the center of the calling button */
  518.  
  519.     n = 0;
  520.     XtSetArg(args[0], XtNwidth, &width); n++;
  521.     XtSetArg(args[1], XtNheight, &height); n++;
  522.     XtGetValues(callLayerPtr->widget, args, n);
  523.     XtTranslateCoords(callLayerPtr->widget, 
  524.               (Position) (width / 2), (Position) (height / 2),
  525.               &x, &y);
  526.  
  527.     if (callLayerPtr->unitType == UI_TARGET)
  528.     unitPtr = &ui_targetUnit;
  529.     else
  530.     unitPtr = &ui_sourceUnit;
  531.  
  532.     /* set start value for the buttons */
  533.     ui_layerStartValue = unitPtr->layers;
  534.     ui_displayLayerPanel(x,y); /* absolute screen coordinates */
  535.     /* assign return value */
  536.     unitPtr->layers = ui_layerReturnValue;
  537.     ui_sel_checkList(ui_currentDisplay, UI_GLOBAL);
  538. }
  539.  
  540.  
  541. #ifdef _UNUSED_FUNCTIONS_
  542.  
  543. /*****************************************************************************
  544.   FUNCTION : ui_info_deleteSite
  545.  
  546.   PURPOSE  : popup the list panel and delete the selected site
  547.   RETURNS  : void
  548.   NOTES    : 
  549.  
  550.   UPDATES  :
  551. *****************************************************************************/
  552.  
  553. static void ui_info_deleteSite(Widget w, 
  554.     struct SimpleListType *listDescriptorPtr, caddr_t call_data)
  555.  
  556. {
  557.     /* do some checks */
  558.     if (NOT ui_info_anyUnitSelected(UI_TARGET)) 
  559.     return;
  560.     if (krui_getUnitInputType(listDescriptorPtr->unitPtr->no) != SITES)
  561.     return;
  562.  
  563.     ui_info_displayList(w, listDescriptorPtr, call_data);
  564.  
  565.     /* the list appears */
  566.     /* now consider the return value */
  567.     if (ui_list_returnIndex == XAW_LIST_NONE)
  568.     return; /* DONE pressed without selection */
  569.     
  570.     if (krui_setSite(ui_list_returnName) != UI_SET_OK) {
  571.     ui_confirmOk("This site does not exist on the target unit!");
  572.     return;
  573.     }
  574.     
  575.     (void) krui_deleteSite();
  576. }
  577.  
  578. #endif /* _UNUSED_FUNCTIONS_ */
  579.  
  580.  
  581. /*****************************************************************************
  582.   FUNCTION : ui_info_unitUpdateProc
  583.  
  584.   PURPOSE  : forces the kernal to update unit-data
  585.   RETURNS  : alteration of the network
  586.   NOTES    :
  587.  
  588.   UPDATES  :
  589. *****************************************************************************/
  590.  
  591. void ui_info_unitUpdateProc(Widget w, FlagType flag, caddr_t call_data)
  592.  
  593. {
  594.     struct UnitAttributeType  unit;
  595.     char       buf[UI_MAX_TW_BUFFER_SIZE];
  596.  
  597.     if (ui_info_anyUnitSelected(flag)) {
  598.     ui_sel_reshowItems(ui_currentDisplay, UI_GLOBAL);
  599.     if (flag == UI_SOURCE) 
  600.         unit = ui_sourceUnit;
  601.     else 
  602.         unit = ui_targetUnit;
  603.     ui_net_drawUnit(ui_currentDisplay, UI_GLOBAL,
  604.             unit.no, UI_ERASE);
  605.     if (flag == UI_SOURCE) 
  606.         ui_info_getDisplayedUnitAttributes(&ui_sourceWidgets, &unit);
  607.     else 
  608.         ui_info_getDisplayedUnitAttributes(&ui_targetWidgets, &unit);
  609.  
  610.     ui_info_storeAttributes(unit.no, unit);
  611.     
  612.     /* output messages and graphic */
  613.     
  614.     ui_tw_printMessage("SET unit: "); 
  615.     sprintf(buf,"%d %s [st: %s, ft: %s]\n  act: %8.5f   iact: %8.5f\n  out: %8.5f   bias: %8.5f\n",
  616.         unit.no, unit.name, ui_utilGetIOTypeName(unit.iotype), 
  617.         unit.ftype, unit.act, unit.i_act, unit.out, unit.bias); 
  618.     ui_tw_printMessage(buf); 
  619.     sprintf(buf,"  act-func: %s\n  out-func: %s\n\n", 
  620.         unit.actFuncName, unit.outFuncName);
  621.     ui_tw_printMessage(buf); 
  622.  
  623.     ui_net_drawUnit(ui_currentDisplay, UI_GLOBAL, unit.no, UI_DRAW);
  624.     ui_rem_resetCounter();
  625.     ui_sel_reshowItems(ui_currentDisplay, UI_GLOBAL);
  626.     } else {
  627.     if (flag == UI_SOURCE) {
  628.         unit = ui_sourceUnit;
  629.         ui_info_getDisplayedUnitAttributes(&ui_sourceWidgets, &unit);
  630.     } else {
  631.         unit = ui_targetUnit;
  632.         ui_info_getDisplayedUnitAttributes(&ui_targetWidgets, &unit);
  633.     }
  634.     }
  635. }
  636.  
  637.  
  638. /*****************************************************************************
  639.   FUNCTION : ui_info_linkUpdateProc
  640.  
  641.   PURPOSE  : forces the kernal to update the connection weight of the dis-
  642.              played link.
  643.   RETURNS  : alteration of the network
  644.   NOTES    :
  645.  
  646.   UPDATES  :
  647. *****************************************************************************/
  648.  
  649. void ui_info_linkUpdateProc(Widget w, XtPointer button, caddr_t call_data)
  650.  
  651. {  
  652.     char                buf[UI_MAX_TW_BUFFER_SIZE];
  653.  
  654.     if (NOT ui_info_anyUnitSelected(UI_SOURCE)) return;
  655.  
  656.     if (krui_setCurrentUnit(ui_targetUnit.no) != UI_SET_OK) {
  657.     ui_confirmOk("Can't update link. Invalid target!");
  658.     return;
  659.     }
  660.     if (ui_sourceUnit.no == 0) {
  661.     ui_confirmOk("Can't update link. Invalid source!");
  662.     return;
  663.     }
  664.     if (strlen(ui_link.siteName) > 0) { /* the displayed link was on a site */
  665.     if (krui_setSite(ui_link.siteName) != UI_SET_OK) {
  666.         ui_confirmOk("Can't update link. Invalid site!");
  667.         return;
  668.     }
  669.     } else {
  670.     if (krui_getUnitInputType(ui_targetUnit.no) == SITES) {
  671.         /* no site specified => DIRECT_LINK */
  672.         /* But a unit can't have sites AND direct links ! */
  673.         ui_confirmOk("Can't update link. Invalid site name!");
  674.         return;
  675.     }    
  676.     }    
  677.  
  678.     if (NOT krui_isConnected(ui_sourceUnit.no)) {
  679.     /* no connection from source to current site of target */
  680.     ui_confirmOk("Can't update link. No connection exists.");
  681.     return;
  682.     }
  683.  
  684.     /* all checks positive */
  685.  
  686.     ui_link.weight = krui_getLinkWeight();
  687.     ui_net_drawLink(ui_currentDisplay, UI_GLOBAL,
  688.             ui_sourceUnit.no, ui_targetUnit.no, 
  689.             ui_link.weight, UI_ERASE);
  690.     
  691.     /* set weight */
  692.     krui_setLinkWeight(ui_link.weight = (FlintType)
  693.                ui_xFloatFromAsciiWidget(ui_linkWidgets.weight)); 
  694.     
  695.     /* show messages */
  696.     
  697.     ui_printMessage("update link done.");
  698.     if (krui_getUnitInputType(ui_targetUnit.no) == SITES)
  699.     sprintf(buf,"SET link weight  : %d -> %d : %.8f   *** to site\n\n",
  700.         ui_sourceUnit.no, ui_targetUnit.no, ui_link.weight);
  701.     else
  702.     sprintf(buf,"SET link weight  : %d -> %d : %.8f   *** direct\n\n",
  703.         ui_sourceUnit.no, ui_targetUnit.no, ui_link.weight);
  704.  
  705.     ui_tw_printMessage(buf); 
  706.     
  707.     ui_net_drawLink(ui_currentDisplay, UI_GLOBAL,
  708.             ui_sourceUnit.no, ui_targetUnit.no, 
  709.             ui_link.weight, UI_DRAW);
  710. }
  711.  
  712.  
  713. /*****************************************************************************
  714.   FUNCTION : ui_info_showSuccOfSourceUnit
  715.  
  716.   PURPOSE  : Display the successor at succPosition in the row TARGET and show
  717.              the weight of the assigned link
  718.   RETURNS  : alteration of unit-info-panel
  719.   NOTES    : If no unit is found at succPosition, this routine shows dummy
  720.              values. Give a position with at least one coordinate set as
  721.          0 to show, that a source unit has now successors.
  722.  
  723.   UPDATES  :
  724. *****************************************************************************/
  725.  
  726. static void ui_info_showSuccOfSourceUnit(int succNo, FlintType weight)
  727.  
  728. {
  729.     ui_info_initLinkStruct();
  730.  
  731.     if ((NOT ui_info_anyUnitSelected(UI_SOURCE)) OR
  732.     ((ui_targetUnit.no = succNo) == 0)) {
  733.     /* show dummy values */
  734.     ui_info_initUnitStruct(&ui_targetUnit);    
  735.     } else {    
  736.     /* SOURCE exists, get values of target with succNo */
  737.     ui_info_getAllUnitData(ui_targetUnit.no, &ui_targetUnit);
  738.     if (krui_getUnitInputType(ui_targetUnit.no) == SITES)
  739.         ui_info_getAllSiteData(); 
  740.     ui_link.weight = weight;
  741.     }
  742.     ui_info_setLinkItems();
  743.     ui_info_setUnitItems(ui_targetWidgets, ui_targetUnit);
  744. }
  745.  
  746.  
  747. /*****************************************************************************
  748.   FUNCTION : ui_info_showPredOfTargetUnit
  749.  
  750.   PURPOSE  : Display the predecessor witgh  predNo in the row SOURCE and show
  751.              the data of this link
  752.   RETURNS  : alteration of unit-info-panel
  753.   NOTES    : If no unit is found with predNo, this routine shows dummy
  754.              values. predNo == 0 means, that no predecessor exists. 
  755.  
  756.   UPDATES  :
  757. *****************************************************************************/
  758.  
  759. void ui_info_showPredOfTargetUnit(int predNo, FlintType weight)
  760.  
  761. {
  762.     if ((NOT ui_info_anyUnitSelected(UI_TARGET)) OR
  763.     ((ui_sourceUnit.no = predNo) == 0)) {
  764.     /* show dummy values */
  765.     ui_info_initUnitStruct(&ui_sourceUnit);
  766.     } else {    
  767.     /* get values */
  768.     ui_info_getAllUnitData(predNo, &ui_sourceUnit);
  769.     ui_link.weight = weight;
  770.     }
  771.     ui_info_setLinkItems();
  772.     ui_info_setUnitItems(ui_sourceWidgets, ui_sourceUnit);
  773. }
  774.  
  775.  
  776. /*****************************************************************************
  777.   FUNCTION : ui_info_showFirstSuccOfSourceUnit
  778.  
  779.   PURPOSE  : search the first successor of the current source unit and display
  780.              the values in the TARGET row.
  781.   RETURNS  : alteration of unit-info-panel
  782.   NOTES    : 
  783.  
  784.   UPDATES  :
  785. *****************************************************************************/
  786.  
  787. void ui_info_showFirstSuccOfSourceUnit(Widget w, XtPointer button, 
  788.     caddr_t call_data)
  789.  
  790. {
  791.     FlintType  weight = 0.0;
  792.  
  793.     ui_targetUnit.no  = 0;
  794.  
  795.     ui_info_initLinkStruct();
  796.  
  797.     if (ui_info_anyUnitSelected(UI_SOURCE)) {
  798.     ui_targetUnit.no = 
  799.         krui_getFirstSuccUnit(ui_sourceUnit.no, &weight);
  800.     if ((ui_targetUnit.no != 0) AND 
  801.         (krui_getUnitInputType(ui_targetUnit.no) == SITES)) {
  802.         /* it is shure, there is a current site */
  803.         ui_info_getAllSiteData();
  804.     }
  805.     }                  
  806.     ui_info_showSuccOfSourceUnit(ui_targetUnit.no, (FlintType) weight);
  807. }
  808.  
  809.  
  810. /*****************************************************************************
  811.   FUNCTION : ui_info_showNextSuccOfSourceUnit
  812.  
  813.   PURPOSE  : search the next successor of the current source unit and display
  814.              the values in the TARGET row.
  815.   RETURNS  : alteration of unit-info-panel
  816.   NOTES    : 
  817.  
  818.   UPDATES  :
  819. *****************************************************************************/
  820.  
  821. void ui_info_showNextSuccOfSourceUnit(Widget w, XtPointer button, 
  822.     caddr_t call_data)
  823.  
  824. {
  825.     FlintType  weight = 0.0;
  826.     int        unitNo;
  827.  
  828.     ui_info_initLinkStruct();
  829.  
  830.     if (ui_info_anyUnitSelected(UI_SOURCE)) {
  831.     if (ui_info_anyUnitSelected(UI_TARGET)) {
  832.         if (krui_isConnected(ui_sourceUnit.no)) {
  833.         (void) krui_setCurrentUnit(ui_sourceUnit.no);
  834.         if ((unitNo = krui_getNextSuccUnit(&weight)) > 0)
  835.             ui_targetUnit.no = unitNo;
  836.         if (krui_getUnitInputType(ui_targetUnit.no) == SITES) {
  837.             /* it is shure, there is a current site */
  838.             ui_info_getAllSiteData();
  839.         }
  840.         ui_info_showSuccOfSourceUnit(ui_targetUnit.no, weight);
  841.         } else 
  842.         ui_info_showFirstSuccOfSourceUnit(NULL, NULL, NULL);
  843.     }
  844.     }
  845. }
  846.  
  847.  
  848. /*****************************************************************************
  849.   FUNCTION : ui_info_showFirstPredOfTargetUnit
  850.  
  851.   PURPOSE  : search the first predecessor of the current target unit and 
  852.              display the values in the SOURCE row.
  853.   RETURNS  : alteration of unit-info-panel
  854.   NOTES    : 
  855.  
  856.   UPDATES  :
  857. *****************************************************************************/
  858.  
  859. void ui_info_showFirstPredOfTargetUnit(Widget w, XtPointer button, 
  860.     caddr_t call_data)
  861.  
  862. {
  863.     FlintType    weight = 0.0;
  864.  
  865.     ui_sourceUnit.no = 0;
  866.  
  867.     if (ui_info_anyUnitSelected(UI_TARGET)) {
  868.     (void) krui_setCurrentUnit(ui_targetUnit.no);
  869.     if (ui_krui_setCurrentSite(ui_targetUnit.no, ui_link.siteName)) { 
  870.         if (krui_getUnitInputType(ui_targetUnit.no) == SITES)
  871.         ui_info_getAllSiteData();
  872.         else
  873.         ui_info_initLinkStruct();
  874.     }    
  875.     ui_sourceUnit.no = krui_getFirstPredUnit(&weight);
  876.     }    
  877.     ui_info_showPredOfTargetUnit(ui_sourceUnit.no, weight);
  878. }
  879.  
  880.  
  881. /*****************************************************************************
  882.   FUNCTION : ui_info_showNextPredOfTargetUnit
  883.  
  884.   PURPOSE  : search the next predecessor of the current target unit and 
  885.              display the values in the SOURCE row.
  886.   RETURNS  : alteration of unit-info-panel
  887.   NOTES    : 
  888.  
  889.   UPDATES  :
  890. *****************************************************************************/
  891.  
  892. void ui_info_showNextPredOfTargetUnit(Widget w, XtPointer button, 
  893.     caddr_t call_data)
  894.  
  895. {
  896.     FlintType   weight = 0.0;
  897.     int         unitNo;
  898.  
  899.     if (NOT ui_info_anyUnitSelected(UI_TARGET)) 
  900.     return;
  901.  
  902.     if (krui_getUnitInputType(ui_targetUnit.no) == SITES) {
  903.     if (strlen(ui_link.siteName)) {
  904.         if (krui_setSite(ui_link.siteName) != UI_SET_OK) { 
  905.         if (krui_setFirstSite())
  906.             ui_info_getAllSiteData();
  907.         } else /* this site exist: get all site data */
  908.         ui_info_getAllSiteData();
  909.     } else { /* invalid site name */
  910.         if (krui_setFirstSite())
  911.         ui_info_getAllSiteData();
  912.     }
  913.     } else /* unit with direct links */
  914.     ui_info_initLinkStruct();
  915.     
  916.     if (krui_isConnected(ui_sourceUnit.no)) {
  917.     /* Now, all CURRENT pointers in the kernel are set correctly */
  918.     if ((unitNo = krui_getNextPredUnit(&weight)) > 0) {
  919.         ui_sourceUnit.no = unitNo;
  920.     }
  921.     ui_info_showPredOfTargetUnit(ui_sourceUnit.no, weight);
  922.     } else { /* not connected => illegal operation */
  923.     ui_confirmOk("Invalid source: not connected with target!");
  924.     }
  925. }
  926.  
  927.  
  928. /*****************************************************************************
  929.   FUNCTION : ui_info_showFirstSiteOfTargetUnit
  930.  
  931.   PURPOSE  : display the next site and the first predecessor on it
  932.   RETURNS  : alteration of unit-info-panel
  933.   NOTES    : 
  934.  
  935.   UPDATES  :
  936. *****************************************************************************/
  937.  
  938. void ui_info_showFirstSiteOfTargetUnit(Widget w, caddr_t lient_data,  
  939.     caddr_t  call_data)
  940.  
  941. {
  942.     ui_info_initLinkStruct();
  943.  
  944.     if (NOT ui_info_anyUnitSelected(UI_TARGET)) {
  945.     ui_confirmOk("Invalid target!");
  946.     return;
  947.     }
  948.  
  949.     if (krui_getUnitInputType(ui_targetUnit.no) != SITES) {
  950.     ui_info_showFirstPredOfTargetUnit(NULL, NULL, NULL);
  951.     return;
  952.     }
  953.  
  954.     if (krui_setFirstSite()) {
  955.     ui_info_getAllSiteData();
  956.     ui_info_showFirstPredOfTargetUnit(NULL, NULL, NULL);
  957.     } /* else is impossible !! */
  958. }
  959.  
  960.  
  961. /*****************************************************************************
  962.   FUNCTION : ui_info_showNextSiteOfTargetUnit
  963.  
  964.   PURPOSE  : display the next site and the first predecessor on it
  965.   RETURNS  : alteration of unit-info-panel
  966.   NOTES    : 
  967.  
  968.   UPDATES  :
  969. *****************************************************************************/
  970.  
  971. void ui_info_showNextSiteOfTargetUnit(Widget w, caddr_t client_data, 
  972.     caddr_t call_data)
  973.  
  974. {
  975.     if (NOT ui_info_anyUnitSelected(UI_TARGET)) {
  976.     ui_confirmOk("Invalid target!");
  977.     return;
  978.     }
  979.  
  980.     if (krui_getUnitInputType(ui_targetUnit.no) != SITES) 
  981.     return;
  982.  
  983.     if (strlen(ui_link.siteName)) {
  984.     if (krui_setSite(ui_link.siteName) != UI_SET_OK) {
  985.         krui_setFirstSite();
  986.         ui_info_getAllSiteData();
  987.         ui_info_showFirstPredOfTargetUnit(NULL, NULL, NULL);
  988.     } else {
  989.         if (krui_setNextSite()) {
  990.         ui_info_getAllSiteData();
  991.         ui_info_showFirstPredOfTargetUnit(NULL, NULL, NULL);
  992.         }
  993.         /* else (= no more sites) leave the panel unchanged */
  994.     }
  995.     } else { /* invalid site in ui_link.siteName */
  996.     krui_setFirstSite();
  997.     ui_info_getAllSiteData();
  998.     ui_info_showFirstPredOfTargetUnit(NULL, NULL, NULL);
  999.     }
  1000. }
  1001.  
  1002.  
  1003. /*****************************************************************************
  1004.   FUNCTION : ui_info_showSelectedUnit
  1005.  
  1006.   PURPOSE  : search and display as source unit the unit at the given position.
  1007.              Because this routine is called caused by an event in a graphik
  1008.          window, the calling argument is a position (raster).
  1009.   RETURNS  : alteration of unit-info-panel
  1010.   NOTES    : if no unit at this position will be found, this routine will
  1011.              display dummy values. 
  1012.  
  1013.   UPDATES  :
  1014. *****************************************************************************/
  1015.  
  1016. void ui_info_showSelectedUnit(int unitNo)
  1017.  
  1018. {
  1019.     if (krui_setCurrentUnit(unitNo) == UI_SET_OK) { /* show values */
  1020.     ui_targetUnit.no = unitNo;
  1021.     ui_info_getAllUnitData(ui_targetUnit.no, &ui_targetUnit);
  1022.     } else { /* show dummy values */
  1023.     ui_targetUnit.no = 0;
  1024.     ui_printMessage("No target unit selected !");
  1025.     ui_info_initUnitStruct(&ui_targetUnit);
  1026.     }
  1027.     ui_info_setUnitItems(ui_targetWidgets, ui_targetUnit);
  1028.     ui_info_showFirstSiteOfTargetUnit(NULL, NULL, NULL);
  1029. }
  1030.  
  1031.  
  1032. /*****************************************************************************
  1033.   FUNCTION : ui_info_showFirstUnit
  1034.  
  1035.   PURPOSE  : search and display the first unit found by the kernal in his
  1036.              data structure.
  1037.   RETURNS  : alteration of unit-info-panel
  1038.   NOTES    : if no unit at this position will be found, this routine will
  1039.              display dummy values. 
  1040.  
  1041.   UPDATES  :
  1042. *****************************************************************************/
  1043.  
  1044. static void ui_info_showFirstUnit(void)
  1045.  
  1046. {
  1047.     ui_targetUnit.no = 0;
  1048.  
  1049.     if ((ui_targetUnit.no = krui_getFirstUnit()) <= 0) {
  1050.     /* no unit available */
  1051.     ui_info_initLinkStruct();
  1052.     ui_info_showFirstPredOfTargetUnit(NULL, NULL, NULL);    
  1053.     ui_printMessage("The network is empty!");
  1054.     }
  1055.     ui_info_showSelectedUnit(ui_targetUnit.no);
  1056. }
  1057.  
  1058.  
  1059. #ifdef _UNUSED_FUNCTIONS_
  1060.  
  1061. /*****************************************************************************
  1062.   FUNCTION : ui_info_makeTargetToSourceUnit
  1063.  
  1064.   PURPOSE  : The current target unit will become the source unit. The TARGET 
  1065.              row will show the first successor of TARGET (if any).
  1066.   RETURNS  : alteration of unit-info-panel
  1067.   NOTES    : if target is invalid, the confirmer will give a message stating
  1068.          this.
  1069.              !!! function is not used yet
  1070.  
  1071.   UPDATES  :
  1072. *****************************************************************************/
  1073.  
  1074. /*!*/ /* not used */
  1075. static void ui_info_makeTargetToSourceUnit(void)
  1076.  
  1077. {
  1078.     if (krui_setCurrentUnit(ui_targetUnit.no) == UI_SET_OK)
  1079.     ui_info_showSelectedUnit(ui_targetUnit.no);
  1080.     else
  1081.     ui_printMessage("Can't make target current source!");
  1082. }
  1083.  
  1084. #endif /* _UNUSED_FUNCTIONS_ */
  1085.  
  1086.  
  1087. #ifdef _UNUSED_FUNCTIONS_ 
  1088.  
  1089. /*****************************************************************************
  1090.   FUNCTION : ui_info_makeSourceToTargetUnit
  1091.  
  1092.   PURPOSE  : The current source unit will become the target unit. The SOURCE 
  1093.              row will show the first predecessor of SOURCE (if any).
  1094.   RETURNS  : alteration of unit-info-panel
  1095.   NOTES    : if source is invalid, the confirmer will give a message stating
  1096.            : this.
  1097.              !!! function is not used yet
  1098.  
  1099.   UPDATES  :
  1100. *****************************************************************************/
  1101.  
  1102. /*!*/ /* not used */
  1103. static void ui_info_makeSourceToTargetUnit(void)
  1104.  
  1105. {
  1106.     if (krui_setCurrentUnit(ui_sourceUnit.no) == UI_SET_OK)
  1107.     ui_info_showSelectedUnit(ui_sourceUnit.no);
  1108.     else
  1109.     ui_printMessage("Can't make source current target!");
  1110. }
  1111.  
  1112. #endif /* _UNUSED_FUNCTIONS_ */
  1113.  
  1114.  
  1115. #ifdef _UNUSED_FUNCTIONS_
  1116.  
  1117. /*****************************************************************************
  1118.   FUNCTION : ui_info_listAllUnits
  1119.  
  1120.   PURPOSE  : list all units with all attributes in the text window
  1121.   RETURNS  : alteration of the text window
  1122.   NOTES    : !!! function is not used yet
  1123.  
  1124.   UPDATES  :
  1125. *****************************************************************************/
  1126.  
  1127. /*!*/ /* not used */
  1128. static void ui_info_listAllUnits(Widget w, XtPointer button, caddr_t call_data)
  1129.  
  1130. {
  1131.     int                       unitNo;
  1132.     struct UnitAttributeType  unit;
  1133.  
  1134.     char                buf[UI_MAX_TW_BUFFER_SIZE];
  1135.     Bool                successful;
  1136.  
  1137.     successful = ((unitNo = krui_getFirstUnit()) > 0);
  1138.  
  1139.     if (NOT successful) 
  1140.     ui_printMessage("The Network is empty!");
  1141.     else {
  1142.     ui_printMessage("Listing all units ...");
  1143.     /* ui_displayText_proc(); */
  1144.     ui_tw_printMessage("\n\nlisting of all units:\n");
  1145.     ui_tw_printMessage("format: NUMBER NAME [FTYPE] ACTIVATION (OUTPUT):BIAS\n");
  1146.          
  1147.     while (successful) {
  1148.         
  1149.         ui_info_getAllUnitData(unitNo, &unit);
  1150.         
  1151.         sprintf(buf,"   %6d %s [%s] %8.5f (%8.5f):%8.5f\n", unit.no, unit.name, 
  1152.             unit.ftype, unit.act, unit.out, unit.bias);
  1153.         ui_tw_printMessage(buf); 
  1154.         
  1155.         successful = ((unitNo = krui_getNextUnit()) > 0);
  1156.     }
  1157.  
  1158.     ui_tw_printMessage("\n\nend of listing\n\n\n");
  1159.     ui_printMessage("");
  1160.     }
  1161. }
  1162.  
  1163. #endif /* _UNUSED_FUNTIONS_ */
  1164.  
  1165.  
  1166. /*****************************************************************************
  1167.   FUNCTION : ui_info_listAllTargetUnits
  1168.  
  1169.   PURPOSE  : list all successors of the current SOURCE in the text window
  1170.   RETURNS  : alteration of the text window
  1171.   NOTES    :
  1172.  
  1173.   UPDATES  :
  1174. *****************************************************************************/
  1175.  
  1176. void ui_info_listAllTargetUnits(Widget w, int unitType, caddr_t call_data)
  1177.  
  1178. {
  1179.     int                       tarNo, sourceNo;
  1180.     struct UnitAttributeType  targetUnit;
  1181.     FlintType                 weight; 
  1182.     char      *name;
  1183.     char      buf[UI_MAX_TW_BUFFER_SIZE];
  1184.     Bool      successful;
  1185.  
  1186.     if (NOT ui_info_anyUnitSelected(unitType)) 
  1187.     return;
  1188.  
  1189.     if (unitType == UI_SOURCE) {
  1190.     sourceNo = ui_sourceUnit.no;
  1191.     name     = ui_sourceUnit.name;
  1192.     } else {
  1193.     sourceNo = ui_targetUnit.no;
  1194.     name     = ui_targetUnit.name;
  1195.     }
  1196.  
  1197.     if (NOT (successful = 
  1198.          ((tarNo = krui_getFirstSuccUnit(sourceNo, &weight)) > 0))) {
  1199.     ui_printMessage("This unit has no successors!");
  1200.     return;
  1201.     }
  1202.  
  1203.     ui_printMessage("Listing all successors ...");
  1204.     /* ui_displayText_proc(); */
  1205.     sprintf(buf,"\n\nListing of all successors of unit %d - %s\n\n", sourceNo,name);
  1206.     ui_tw_printMessage(buf);
  1207.     ui_tw_printMessage("  weight    -> number - name                 output    activat.  bias\n");
  1208.     ui_tw_printMessage("---------------------------------------------------------------------------\n");
  1209.     while (successful) {
  1210.     ui_info_getAllUnitData(tarNo, &targetUnit);
  1211.     
  1212.     sprintf(buf,"  %9.5f -> %6d - %-20s %8.5f  %8.5f  %9.5f\n", 
  1213.         weight, targetUnit.no, targetUnit.name, targetUnit.out, 
  1214.         targetUnit.act, targetUnit.bias);
  1215.     ui_tw_printMessage(buf);
  1216.     
  1217.     ui_krui_setCurrentLink(sourceNo, tarNo, "");
  1218.     (void) krui_setCurrentUnit(sourceNo);
  1219.     successful = ((tarNo = krui_getNextSuccUnit(&weight)) > 0);
  1220.     }
  1221.     ui_tw_printMessage("\n\nend of listing\n\n\n");
  1222.     ui_printMessage("");
  1223. }
  1224.  
  1225.  
  1226. /*****************************************************************************
  1227.   FUNCTION : ui_info_listAllSourceUnits
  1228.  
  1229.   PURPOSE  : list all predecessors of the current TARGET in the text window
  1230.   RETURNS  : alteration of the text window
  1231.   NOTES    :
  1232.  
  1233.   UPDATES  :
  1234. *****************************************************************************/
  1235.  
  1236. void ui_info_listAllSourceUnits(Widget w, int unitType, caddr_t call_data)
  1237.  
  1238. {
  1239.     int                       targetNo, srcNo;
  1240.     struct UnitAttributeType  sourceUnit;
  1241.     FlintType                 weight; 
  1242.     char      *name;
  1243.     char      buf[UI_MAX_TW_BUFFER_SIZE];
  1244.     Bool      successful;
  1245.     Bool      siteIsActive;
  1246.  
  1247.     if (NOT ui_info_anyUnitSelected(unitType)) 
  1248.     return;
  1249.  
  1250.     if (unitType == UI_SOURCE) {
  1251.     targetNo = ui_sourceUnit.no;
  1252.     name     = ui_sourceUnit.name;
  1253.     } else {
  1254.     targetNo = ui_targetUnit.no;
  1255.     name     = ui_targetUnit.name;
  1256.     }
  1257.    
  1258.     (void) krui_setCurrentUnit(targetNo);
  1259.     
  1260.     ui_printMessage("Listing of all predecessors ...");
  1261.     /* ui_displayText_proc(); */
  1262.     sprintf(buf,"\n\nListing of all predecessors of unit %d - %s\n\n", targetNo, name);
  1263.     ui_tw_printMessage(buf);
  1264.     ui_tw_printMessage("  weight    <- number - name                 output    activat.  bias\n");
  1265.     ui_tw_printMessage("---------------------------------------------------------------------------\n");
  1266.  
  1267.     siteIsActive = krui_setFirstSite();
  1268.  
  1269.     do { /* loop over all sites */ 
  1270.     if (siteIsActive) {
  1271.         sprintf(buf,"\nsite: %-20s  (func: %-20s)  value: %9.5f\n",
  1272.             krui_getSiteName(), krui_getSiteFuncName(), 
  1273.             krui_getSiteValue());
  1274.         ui_tw_printMessage(buf);
  1275.     }
  1276.     successful = 
  1277.         ((srcNo = krui_getFirstPredUnit(&weight)) > 0);
  1278.     
  1279.     while (successful) {
  1280.         ui_info_getAllUnitData(srcNo, &sourceUnit);
  1281.         
  1282.         sprintf(buf,"  %9.5f <- %6d - %-20s %8.5f  %8.5f  %9.5f\n", 
  1283.             weight, srcNo, sourceUnit.name, sourceUnit.out, 
  1284.             sourceUnit.act, sourceUnit.bias);
  1285.         ui_tw_printMessage(buf);
  1286.         
  1287.         successful = ((srcNo = krui_getNextPredUnit(&weight)) > 0);
  1288.     } /* end while */
  1289.  
  1290.     } while ((siteIsActive = krui_setNextSite()));
  1291.  
  1292.     ui_tw_printMessage("\n\nend of listing\n\n\n");
  1293.     ui_printMessage("");
  1294. }
  1295.  
  1296.  
  1297. /*****************************************************************************
  1298.   FUNCTION : ui_info_listAllSites
  1299.  
  1300.   PURPOSE  : list all predecessors of the current TARGET in the text window
  1301.   RETURNS  : alteration of the text window
  1302.   NOTES    :
  1303.  
  1304.   UPDATES  :
  1305. *****************************************************************************/
  1306.  
  1307. void ui_info_listAllSites(Widget w, int unitType, caddr_t call_data)
  1308.  
  1309. {
  1310.     int       targetNo;
  1311.     char      *name;
  1312.     char      buf[UI_MAX_TW_BUFFER_SIZE];
  1313.     Bool      siteIsActive;
  1314.  
  1315.     if (NOT ui_info_anyUnitSelected(unitType)) 
  1316.     return;
  1317.  
  1318.     if (unitType == UI_SOURCE) {
  1319.     targetNo = ui_sourceUnit.no;
  1320.     name     = ui_sourceUnit.name;
  1321.     } else {
  1322.     targetNo = ui_targetUnit.no;
  1323.     name     = ui_targetUnit.name;
  1324.     }
  1325.    
  1326.     (void) krui_setCurrentUnit(targetNo);
  1327.     
  1328.     ui_printMessage("Listing of all sites ...");
  1329.     /* ui_displayText_proc(); */
  1330.     sprintf(buf,"\n\nListing of all sites of unit %d - %s\n\n", targetNo, name);
  1331.     ui_tw_printMessage(buf);
  1332.     ui_tw_printMessage("  site name                   site function                   value\n");
  1333.     ui_tw_printMessage("---------------------------------------------------------------------------\n");
  1334.  
  1335.     siteIsActive = krui_setFirstSite();
  1336.  
  1337.     do { /* loop over all sites */ 
  1338.     if (siteIsActive) {
  1339.         sprintf(buf,"  %-24s    %-24s    %9.5f\n",
  1340.             krui_getSiteName(), krui_getSiteFuncName(), 
  1341.             krui_getSiteValue());
  1342.         ui_tw_printMessage(buf);
  1343.     }
  1344.     } while ((siteIsActive = krui_setNextSite()));
  1345.     
  1346.     ui_tw_printMessage("\n\nend of listing\n\n\n");
  1347.     ui_printMessage("");
  1348. }
  1349.  
  1350.  
  1351. /*****************************************************************************
  1352.   FUNCTION : ui_info_listAllLinksToCurrentSite
  1353.  
  1354.   PURPOSE  : list all predecessors of the current TARGET in the text window
  1355.   RETURNS  : alteration of the text window
  1356.   NOTES    :
  1357.  
  1358.   UPDATES  :
  1359. *****************************************************************************/
  1360.  
  1361. void ui_info_listAllLinksToCurrentSite(Widget w, int unitType, 
  1362.     caddr_t call_data)
  1363.  
  1364. {
  1365.     int                       srcNo;
  1366.     struct UnitAttributeType  sourceUnit;
  1367.     FlintType                 weight; 
  1368.     char      buf[UI_MAX_TW_BUFFER_SIZE];
  1369.     Bool      successful;
  1370.  
  1371.     if (NOT ui_info_anyUnitSelected(UI_TARGET))
  1372.     return;
  1373.  
  1374.     if (NOT strlen(ui_link.siteName) OR 
  1375.     (krui_setSite(ui_link.siteName) != UI_SET_OK)) {
  1376.     sprintf(buf,"Invalid site <%s>!", ui_link.siteName);
  1377.     ui_confirmOk(buf);
  1378.     return;
  1379.     }
  1380.  
  1381.     ui_printMessage("Listing of all links to current site ...");
  1382.     /* ui_displayText_proc(); */
  1383.     sprintf(buf,"\n\nListing of all links to site %s of unit %d - %s\n\n", 
  1384.         ui_link.siteName, ui_targetUnit.no, ui_targetUnit.name);
  1385.     ui_tw_printMessage(buf);
  1386.     sprintf(buf,"\nsite: %-20s  (func: %-20s)  value: %9.5f\n\n",
  1387.         krui_getSiteName(), krui_getSiteFuncName(), 
  1388.         krui_getSiteValue());
  1389.     ui_tw_printMessage(buf);
  1390.     
  1391.     ui_tw_printMessage("  weight    <- number - name                 output    activat.  bias\n");
  1392.     ui_tw_printMessage("---------------------------------------------------------------------------\n");
  1393.  
  1394.     successful = 
  1395.          ((srcNo = krui_getFirstPredUnit(&weight)) > 0);
  1396.  
  1397.     while (successful) {
  1398.     ui_info_getAllUnitData(srcNo, &sourceUnit);
  1399.     
  1400.     sprintf(buf,"  %9.5f <- %6d - %-20s %8.5f  %8.5f  %9.5f\n", 
  1401.         weight, srcNo, sourceUnit.name, sourceUnit.out, 
  1402.         sourceUnit.act, sourceUnit.bias);
  1403.     ui_tw_printMessage(buf);
  1404.     
  1405.     successful = ((srcNo = krui_getNextPredUnit(&weight)) > 0);
  1406.     } /* end while */
  1407.  
  1408.     ui_tw_printMessage("\n\nend of listing\n\n\n");
  1409.     ui_printMessage("");
  1410. }
  1411.  
  1412.  
  1413. #ifdef _UNUSED_FUNCTIONS_
  1414.  
  1415. /*****************************************************************************
  1416.   FUNCTION : ui_info_listAllLinks
  1417.  
  1418.   PURPOSE  : list all links of the network in forward and backward direction
  1419.   RETURNS  : alteration of the text window
  1420.   NOTES    : !!! function is not used yet
  1421.  
  1422.   UPDATES  :
  1423. *****************************************************************************/
  1424.  
  1425. /*!*/ /* not used */
  1426. static void ui_info_listAllLinks(void)
  1427.  
  1428. {
  1429.     int        sourceNo, targetNo;
  1430.     FlintType  weight; 
  1431.  
  1432.     char      buf[UI_MAX_TW_BUFFER_SIZE];
  1433.     Bool      successful;
  1434.  
  1435.     successful = ((sourceNo = krui_getFirstUnit()) > 0);
  1436.  
  1437.     if (NOT successful) 
  1438.     ui_printMessage("The network is empty!");
  1439.     else {
  1440.     ui_printMessage("Listing all links ...");
  1441.     /* ui_displayText_proc(); */
  1442.     ui_tw_printMessage("\n\nListing of all links of the network\n\n"); 
  1443.     ui_tw_printMessage("Listing forward\n");
  1444.     ui_tw_printMessage("format: SOURCE: TARGET1:WEIGHT1  TARGET2:WEIGHT2  ...\n\n"); 
  1445.  
  1446.     while (successful) {
  1447.  
  1448.         sprintf(buf,"%6d:",sourceNo);
  1449.         ui_tw_printMessage(buf);
  1450.  
  1451.         successful = 
  1452.         ((targetNo = krui_getFirstSuccUnit(sourceNo, &weight)) > 0);
  1453.                
  1454.         while (successful) {
  1455.         sprintf(buf, "  %d:%8.5f", targetNo, weight);
  1456.         ui_tw_printMessage(buf);
  1457.  
  1458.         successful = ((targetNo = krui_getNextSuccUnit(&weight)) > 0);
  1459.         }
  1460.         ui_tw_printMessage("\n");
  1461.         successful = ((sourceNo = krui_getNextUnit()) > 0);
  1462.     }
  1463.     ui_tw_printMessage("\n\n");
  1464.     ui_tw_printMessage("Listing backward\n");
  1465.     ui_tw_printMessage("format: TARGET: SOURCE1:WEIGHT1, SOURCE2:WEIGHT2, ...\n\n");
  1466.     successful = ((targetNo = krui_getFirstUnit()) > 0);
  1467.  
  1468.     while (successful) {
  1469.         sprintf(buf,"%6d:",targetNo);
  1470.         ui_tw_printMessage(buf); 
  1471.  
  1472.         successful = ((sourceNo = krui_getFirstPredUnit(&weight)) > 0);
  1473.         while (successful) {
  1474.         sprintf(buf, "  %d:%8.5f", sourceNo, weight);
  1475.         ui_tw_printMessage(buf);
  1476.  
  1477.         successful = ((sourceNo = krui_getNextPredUnit(&weight)) > 0);
  1478.         }
  1479.         ui_tw_printMessage("\n");
  1480.         successful = ((targetNo = krui_getNextUnit()) > 0);
  1481.     }
  1482.     ui_tw_printMessage("\nend of listing.\n\n");
  1483.     ui_printMessage("");
  1484.     } /* end else : there are unit */
  1485. }
  1486.  
  1487. #endif /* _UNUSED_FUNCTIONS_ */
  1488.  
  1489.  
  1490. /*****************************************************************************
  1491.   FUNCTION : ui_info_makeUnitInfoPanelConsistent
  1492.  
  1493.   PURPOSE  : After deleting units, the unit info panel may show data of a
  1494.              unit, which was deleted. This routine shows then data of a valid
  1495.          unit/successor.
  1496.   RETURNS  : displays values in the unit info panel.
  1497.   NOTES    : Code:
  1498.          if TARGET and SOURCE ok, but not connected or TARGET only, 
  1499.             then display first predecessor of target.
  1500.          if SOURCE only, then display first successor of SOURCE.
  1501.          if both units are invalid, then display "first" connection of
  1502.                 the network (first unit, site, link)
  1503.  
  1504.   UPDATES  :
  1505. *****************************************************************************/
  1506.  
  1507. void ui_info_makeUnitInfoPanelConsistent(void)
  1508.  
  1509. {
  1510.     if (ui_infoIsCreated) {
  1511.     Bool SourceValid = ui_info_anyUnitSelected(UI_SOURCE);
  1512.     Bool TargetValid = ui_info_anyUnitSelected(UI_TARGET);
  1513.     Bool LinkValid   = TargetValid AND 
  1514.         ui_krui_setCurrentSite(ui_targetUnit.no, ui_link.siteName);
  1515.  
  1516.     LinkValid = LinkValid AND krui_isConnected(ui_sourceUnit.no);
  1517.  
  1518.     if ((SourceValid AND TargetValid AND (NOT LinkValid)) OR
  1519.         (TargetValid AND (NOT SourceValid))) {
  1520.         ui_info_showFirstPredOfTargetUnit(NULL, NULL, NULL);
  1521.         return;
  1522.     }
  1523.     
  1524.     if (SourceValid AND (NOT TargetValid)) {
  1525.         ui_info_showFirstSuccOfSourceUnit(NULL, NULL, NULL);
  1526.         return;
  1527.     }
  1528.  
  1529.     if (LinkValid) return; /* everything is ok. */
  1530.  
  1531.     /* nothing is valid */
  1532.     ui_info_showFirstUnit();
  1533.     }
  1534. }
  1535.  
  1536.  
  1537. #ifdef _UNUSED_FUNCTIONS_
  1538.  
  1539. /*****************************************************************************
  1540.   FUNCTION : ui_info_deleteLink
  1541.  
  1542.   PURPOSE  : delete the displayed link
  1543.   RETURNS  : alteration of the network
  1544.   NOTES    : !!! function is not used yet
  1545.  
  1546.   UPDATES  :
  1547. *****************************************************************************/
  1548.  
  1549. /*!*/ /* not used */
  1550. static void ui_info_deleteLink(void)
  1551.  
  1552. {
  1553.     FlintType  weight;
  1554.  
  1555.     if (ui_info_anyUnitSelected(UI_SOURCE) AND
  1556.     ui_info_anyUnitSelected(UI_TARGET)) {
  1557.     /* ask whether both units are connected, set current link pointer */
  1558.     if (NOT ui_krui_setCurrentSite(ui_targetUnit.no, ui_link.siteName)) {
  1559.         ui_confirmOk("Invalid site!");
  1560.         return;
  1561.     }
  1562.     if (NOT krui_isConnected(ui_sourceUnit.no)) {
  1563.         ui_confirmOk("No link exist!");
  1564.         return;
  1565.     }
  1566.  
  1567.     weight = krui_getLinkWeight();
  1568.     krui_deleteLink();
  1569.     ui_net_drawLink(ui_currentDisplay, UI_GLOBAL,
  1570.             ui_sourceUnit.no, ui_targetUnit.no, 
  1571.             weight, UI_ERASE);
  1572.     ui_info_makeUnitInfoPanelConsistent();
  1573.     }
  1574. }
  1575.  
  1576. #endif /* _UNUSED_FUNTIONS_ */
  1577.  
  1578.  
  1579. #ifdef _UNUSED_FUNCTIONS_
  1580.  
  1581. /*****************************************************************************
  1582.   FUNCTION : ui_info_showNextUnit
  1583.  
  1584.   PURPOSE  : search and display the next unit found by the kernal in the
  1585.              data structure.
  1586.   RETURNS  : alteration of unit-info-panel
  1587.   NOTES    : if no unit at this position will be found, this routine will
  1588.              display dummy values. 
  1589.               !!! function is not used yet
  1590.  
  1591.   UPDATES  :
  1592. *****************************************************************************/
  1593.  
  1594. /*!*/ /* not used */
  1595. static void ui_info_showNextUnit(void)
  1596.  
  1597. {
  1598.     ui_info_makeUnitInfoPanelConsistent();
  1599.  
  1600.     if (ui_info_anyUnitSelected(UI_SOURCE)) {
  1601.  
  1602.     krui_setCurrentUnit(ui_sourceUnit.no);
  1603.     ui_sourceUnit.no = krui_getNextUnit();
  1604.  
  1605.     if ((ui_sourceUnit.no = krui_getNextUnit()) > 0) {
  1606.         krui_getUnitPosition(ui_sourceUnit.no, &ui_sourceUnit.gridPos);
  1607.         ui_info_showSelectedUnit(ui_sourceUnit.no);
  1608.     } else 
  1609.         ui_printMessage("No more units in this network !"); 
  1610.     } else 
  1611.     /* the user pressed the NEXT button, but no valid unit was displayed */
  1612.     ui_info_showFirstUnit();
  1613. }
  1614.  
  1615. #endif /* _UNUSED_FUNCTIONS_ */
  1616.  
  1617.  
  1618.  
  1619.  
  1620. /* end of file */
  1621. /* lines: 1622 */
  1622.